package cn.itlaobing.service.impl;

import cn.itlaobing.dao.UserDao;
import cn.itlaobing.exception.BusinessException;
import cn.itlaobing.model.OrderModel;
import cn.itlaobing.model.UserModel;
import cn.itlaobing.service.UserService;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/11/2.
 */
public class UserServiceImpl implements UserService {
    UserDao userDao=new UserDao();
    @Override
    public UserModel authentication(String username, String password) throws BusinessException {
        UserModel um=new UserModel();
        try {
            um=userDao.authentication(username);
            if(um==null){
                return um;
            }
            if(!um.getUserPass().equals(password)){
                return  null;
            }
            userDao.updateLastTime(um.getUserId());

        } catch (SQLException e) {
            e.printStackTrace();
            throw new BusinessException(e.getMessage());
        }

        return um;
    }

}
